﻿using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using DeepCopy;
using SaveAssist;
using UnityEngine;

// Token: 0x020002D8 RID: 728
public abstract class CharFile
{
	// Token: 0x060011A9 RID: 4521 RVA: 0x0008FFBC File Offset: 0x0008E1BC
	public CharFile(string fileMarkName, string fileDirectory)
	{
		this.CharaFileMark = fileMarkName;
		this.CharaFileDirectory = fileDirectory;
		this.previewInfo = new global::CharFileInfoPreview();
		this.customInfo = null;
		this.coordinateInfo = null;
		this.statusInfo = null;
		this.parameterInfo = null;
		this.clothesInfo = null;
	}

	// Token: 0x17000274 RID: 628
	// (get) Token: 0x060011AA RID: 4522 RVA: 0x00090038 File Offset: 0x0008E238
	// (set) Token: 0x060011AB RID: 4523 RVA: 0x00090040 File Offset: 0x0008E240
	public global::CharFileInfoPreview previewInfo { get; set; }

	// Token: 0x17000275 RID: 629
	// (get) Token: 0x060011AC RID: 4524 RVA: 0x0009004C File Offset: 0x0008E24C
	// (set) Token: 0x060011AD RID: 4525 RVA: 0x00090054 File Offset: 0x0008E254
	public global::CharFileInfoCustom customInfo { get; set; }

	// Token: 0x17000276 RID: 630
	// (get) Token: 0x060011AE RID: 4526 RVA: 0x00090060 File Offset: 0x0008E260
	// (set) Token: 0x060011AF RID: 4527 RVA: 0x00090068 File Offset: 0x0008E268
	public global::CharFileInfoCoordinate coordinateInfo { get; set; }

	// Token: 0x17000277 RID: 631
	// (get) Token: 0x060011B0 RID: 4528 RVA: 0x00090074 File Offset: 0x0008E274
	// (set) Token: 0x060011B1 RID: 4529 RVA: 0x0009007C File Offset: 0x0008E27C
	public global::CharFileInfoStatus statusInfo { get; set; }

	// Token: 0x17000278 RID: 632
	// (get) Token: 0x060011B2 RID: 4530 RVA: 0x00090088 File Offset: 0x0008E288
	// (set) Token: 0x060011B3 RID: 4531 RVA: 0x00090090 File Offset: 0x0008E290
	public global::CharFileInfoParameter parameterInfo { get; set; }

	// Token: 0x17000279 RID: 633
	// (get) Token: 0x060011B4 RID: 4532 RVA: 0x0009009C File Offset: 0x0008E29C
	// (set) Token: 0x060011B5 RID: 4533 RVA: 0x000900A4 File Offset: 0x0008E2A4
	public global::CharFileInfoClothes clothesInfo { get; set; }

	// Token: 0x060011B6 RID: 4534 RVA: 0x000900B0 File Offset: 0x0008E2B0
	public void CopyBlockData<T>(T srcInfo) where T : global::BlockControlBase
	{
		if (srcInfo is global::CharFileInfoPreview)
		{
			global::CharFileInfoPreview target = srcInfo as global::CharFileInfoPreview;
			this.previewInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoPreview>(target);
		}
		else if (srcInfo is global::CharFileInfoCustomMale)
		{
			global::CharFileInfoCustomMale target2 = srcInfo as global::CharFileInfoCustomMale;
			this.customInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoCustomMale>(target2);
		}
		else if (srcInfo is global::CharFileInfoCustomFemale)
		{
			global::CharFileInfoCustomFemale target3 = srcInfo as global::CharFileInfoCustomFemale;
			this.customInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoCustomFemale>(target3);
		}
		else if (srcInfo is global::CharFileInfoCoordinateMale)
		{
			global::CharFileInfoCoordinateMale target4 = srcInfo as global::CharFileInfoCoordinateMale;
			this.coordinateInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoCoordinateMale>(target4);
		}
		else if (srcInfo is global::CharFileInfoCoordinateFemale)
		{
			global::CharFileInfoCoordinateFemale target5 = srcInfo as global::CharFileInfoCoordinateFemale;
			this.coordinateInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoCoordinateFemale>(target5);
		}
		else if (srcInfo is global::CharFileInfoStatusMale)
		{
			global::CharFileInfoStatusMale target6 = srcInfo as global::CharFileInfoStatusMale;
			this.statusInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoStatusMale>(target6);
		}
		else if (srcInfo is global::CharFileInfoStatusFemale)
		{
			global::CharFileInfoStatusFemale target7 = srcInfo as global::CharFileInfoStatusFemale;
			this.statusInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoStatusFemale>(target7);
		}
		else if (srcInfo is global::CharFileInfoParameterMale)
		{
			global::CharFileInfoParameterMale target8 = srcInfo as global::CharFileInfoParameterMale;
			this.parameterInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoParameterMale>(target8);
		}
		else if (srcInfo is global::CharFileInfoParameterFemale)
		{
			global::CharFileInfoParameterFemale target9 = srcInfo as global::CharFileInfoParameterFemale;
			this.parameterInfo = DeepCopy.DeepCopyHelper.DeepCopy<global::CharFileInfoParameterFemale>(target9);
		}
	}

	// Token: 0x060011B7 RID: 4535 RVA: 0x00090258 File Offset: 0x0008E458
	public bool SetClothesInfo(global::CharFileInfoClothes info)
	{
		return this.clothesInfo.Copy(info);
	}

	// Token: 0x060011B8 RID: 4536 RVA: 0x00090268 File Offset: 0x0008E468
	public bool ChangeCoordinateType(global::CharDefine.CoordinateType type)
	{
		if (this.coordinateInfo == null)
		{
			return false;
		}
		global::CharFileInfoClothes info = this.coordinateInfo.GetInfo(type);
		if (info == null)
		{
			return false;
		}
		if (this.clothesInfo.Copy(info))
		{
			this.statusInfo.coordinateType = type;
			return true;
		}
		return false;
	}

	// Token: 0x060011B9 RID: 4537 RVA: 0x000902B8 File Offset: 0x0008E4B8
	public bool SetCoordinateInfo(global::CharDefine.CoordinateType type)
	{
		return this.coordinateInfo != null && this.coordinateInfo.SetInfo(type, this.clothesInfo);
	}

	// Token: 0x060011BA RID: 4538 RVA: 0x000902DC File Offset: 0x0008E4DC
	public static bool CheckSBPRFile(string path)
	{
		global::CharSave_SexyBeachPR charSave_SexyBeachPR = new global::CharSave_SexyBeachPR(global::CharSave_SexyBeachPR.ConvertType.HoneySelect);
		string fileTag = charSave_SexyBeachPR.GetFileTag(path);
		return !("【PremiumResortCharaFemale】" != fileTag) || !("【PremiumResortCharaMale】" != fileTag);
	}

	// Token: 0x060011BB RID: 4539 RVA: 0x0009031C File Offset: 0x0008E51C
	public static int CheckSBPRFileWithSex(string path)
	{
		global::CharSave_SexyBeachPR charSave_SexyBeachPR = new global::CharSave_SexyBeachPR(global::CharSave_SexyBeachPR.ConvertType.HoneySelect);
		string fileTag = charSave_SexyBeachPR.GetFileTag(path);
		if ("【PremiumResortCharaFemale】" == fileTag)
		{
			return 1;
		}
		if ("【PremiumResortCharaMale】" == fileTag)
		{
			return 0;
		}
		return -1;
	}

	// Token: 0x060011BC RID: 4540
	public abstract bool LoadFromSBPR(string path);

	// Token: 0x060011BD RID: 4541 RVA: 0x00090360 File Offset: 0x0008E560
	public static int CheckHoneySelectCharaFile(string path)
	{
		if (!File.Exists(path))
		{
			return -1;
		}
		int result;
		using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
		{
			using (BinaryReader binaryReader = new BinaryReader(fileStream))
			{
				if (binaryReader.BaseStream.Length == 0L)
				{
					result = -1;
				}
				else
				{
					long num = 0L;
					global::PngAssist.CheckPngData(binaryReader, ref num, true);
					if (binaryReader.BaseStream.Length - binaryReader.BaseStream.Position == 0L)
					{
						global::Debug.LogWarning("ただのPNGファイルの可能性があります。");
						result = -1;
					}
					else
					{
						try
						{
							string b = binaryReader.ReadString();
							int num2 = binaryReader.ReadInt32();
							if ("【HoneySelectCharaMale】" == b)
							{
								if (num2 == 1)
								{
									return 0;
								}
								return 2;
							}
							else
							{
								if (!("【HoneySelectCharaFemale】" == b))
								{
									return -1;
								}
								if (num2 == 1)
								{
									return 1;
								}
								return 3;
							}
						}
						catch (EndOfStreamException ex)
						{
							global::Debug.LogError("データが破損している可能性があります：" + ex.GetType().Name);
						}
						result = -1;
					}
				}
			}
		}
		return result;
	}

	// Token: 0x060011BE RID: 4542 RVA: 0x000904E8 File Offset: 0x0008E6E8
	public static byte[] GetHashPngBytes(byte[] data)
	{
		byte[] array = new byte[32];
		int srcOffset = data.Length - 8 - 8 - 32;
		int num = Marshal.SizeOf(data.GetType().GetElementType());
		Buffer.BlockCopy(data, srcOffset, array, 0, array.Length * num);
		return array;
	}

	// Token: 0x060011BF RID: 4543 RVA: 0x00090528 File Offset: 0x0008E728
	public static string GetHashPngStr(byte[] data)
	{
		byte[] hashPngBytes = global::CharFile.GetHashPngBytes(data);
		StringBuilder stringBuilder = new StringBuilder();
		foreach (byte b in hashPngBytes)
		{
			stringBuilder.Append(b.ToString("x2"));
		}
		return stringBuilder.ToString();
	}

	// Token: 0x060011C0 RID: 4544 RVA: 0x0009057C File Offset: 0x0008E77C
	public byte[] GetHashParamBytes()
	{
		byte[] array = this.customInfo.SaveBytes();
		byte[] array2 = this.coordinateInfo.SaveBytes();
		byte[] array3 = this.parameterInfo.SaveBytes();
		byte[] array4 = new byte[array.Length + array2.Length + array3.Length];
		Array.Copy(array, array4, array.Length);
		Array.Copy(array2, 0, array4, array.Length, array2.Length);
		Array.Copy(array3, 0, array4, array.Length + array2.Length, array3.Length);
		return global::YS_Assist.CreateSha256(array4, this.CharaFileMark);
	}

	// Token: 0x060011C1 RID: 4545 RVA: 0x000905F4 File Offset: 0x0008E7F4
	public string GetHashParamStr()
	{
		byte[] hashParamBytes = this.GetHashParamBytes();
		StringBuilder stringBuilder = new StringBuilder();
		foreach (byte b in hashParamBytes)
		{
			stringBuilder.Append(b.ToString("x2"));
		}
		return stringBuilder.ToString();
	}

	// Token: 0x060011C2 RID: 4546 RVA: 0x00090648 File Offset: 0x0008E848
	public string ConvertCharaFilePath(string path, bool newFile = false)
	{
		string text = string.Empty;
		string text2 = string.Empty;
		if (path != string.Empty)
		{
			text = Path.GetDirectoryName(path);
			text2 = Path.GetFileName(path);
		}
		if (text == string.Empty)
		{
			text = global::UserData.Path + this.CharaFileDirectory;
		}
		else
		{
			text += "/";
		}
		if (text2 == string.Empty)
		{
			if (newFile || this.charaFileName == string.Empty)
			{
				string empty = string.Empty;
				if (this.CharaFileMark == "【HoneySelectCharaMale】")
				{
					text2 = "charaM" + empty + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
				}
				else
				{
					text2 = "charaF" + empty + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
				}
			}
			else
			{
				text2 = this.charaFileName;
			}
		}
		this.charaFileName = Path.GetFileNameWithoutExtension(text2) + ".png";
		return text + this.charaFileName;
	}

	// Token: 0x060011C3 RID: 4547 RVA: 0x00090774 File Offset: 0x0008E974
	public bool Save(string path = "")
	{
		string path2 = this.ConvertCharaFilePath(path, false);
		string directoryName = Path.GetDirectoryName(path2);
		if (!Directory.Exists(directoryName))
		{
			Directory.CreateDirectory(directoryName);
		}
		bool result;
		using (FileStream fileStream = new FileStream(path2, FileMode.Create, FileAccess.Write))
		{
			result = this.Save(fileStream);
		}
		return result;
	}

	// Token: 0x060011C4 RID: 4548 RVA: 0x000907DC File Offset: 0x0008E9DC
	public bool Save(Stream st)
	{
		bool result;
		using (BinaryWriter binaryWriter = new BinaryWriter(st))
		{
			result = this.Save(binaryWriter);
		}
		return result;
	}

	// Token: 0x060011C5 RID: 4549 RVA: 0x00090820 File Offset: 0x0008EA20
	public bool Save(BinaryWriter writer)
	{
		if (this.charaFilePNG != null)
		{
			writer.Write(this.charaFilePNG);
		}
		return this.SaveWithoutPNG(writer);
	}

	// Token: 0x060011C6 RID: 4550 RVA: 0x00090840 File Offset: 0x0008EA40
	public bool SaveWithoutPNG(BinaryWriter writer)
	{
		long position = writer.BaseStream.Position;
		writer.Write(this.CharaFileMark);
		writer.Write(2);
		byte[] array = null;
		if (this.previewInfo != null)
		{
			this.previewInfo.Update(this);
			array = this.previewInfo.SaveBytes();
		}
		byte[] array2 = null;
		if (this.customInfo != null)
		{
			array2 = this.customInfo.SaveBytes();
		}
		byte[] array3 = null;
		if (this.coordinateInfo != null)
		{
			array3 = this.coordinateInfo.SaveBytes();
		}
		byte[] array4 = null;
		if (this.statusInfo != null)
		{
			array4 = this.statusInfo.SaveBytes();
		}
		byte[] array5 = null;
		if (this.parameterInfo != null)
		{
			array5 = this.parameterInfo.SaveBytes();
		}
		int num = 5;
		writer.Write(num);
		long num2 = 0L;
		string[] array6 = new string[]
		{
			this.previewInfo.tagName,
			this.customInfo.tagName,
			this.coordinateInfo.tagName,
			this.statusInfo.tagName,
			this.parameterInfo.tagName
		};
		int[] array7 = new int[]
		{
			this.previewInfo.version,
			this.customInfo.version,
			this.coordinateInfo.version,
			this.statusInfo.version,
			this.parameterInfo.version
		};
		long[] array8 = new long[]
		{
			(long)((array != null) ? array.GetLength(0) : 0),
			(long)((array2 != null) ? array2.GetLength(0) : 0),
			(long)((array3 != null) ? array3.GetLength(0) : 0),
			(long)((array4 != null) ? array4.GetLength(0) : 0),
			(long)((array5 != null) ? array5.GetLength(0) : 0)
		};
		long[] array9 = new long[]
		{
			num2,
			num2 + array8[0],
			num2 + array8[0] + array8[1],
			num2 + array8[0] + array8[1] + array8[2],
			num2 + array8[0] + array8[1] + array8[2] + array8[3]
		};
		SaveAssist.BlockHeader[] array10 = new SaveAssist.BlockHeader[num];
		for (int i = 0; i < num; i++)
		{
			array10[i] = new SaveAssist.BlockHeader();
			array10[i].SetHeader(array6[i], array7[i], array9[i], array8[i]);
			array10[i].SaveHeader(writer);
		}
		long value = writer.BaseStream.Position - position;
		if (array8[0] != 0L)
		{
			writer.Write(array);
		}
		if (array8[1] != 0L)
		{
			writer.Write(array2);
		}
		if (array8[2] != 0L)
		{
			writer.Write(array3);
		}
		if (array8[3] != 0L)
		{
			writer.Write(array4);
		}
		if (array8[4] != 0L)
		{
			writer.Write(array5);
		}
		byte[] buffer;
		if (this.charaFilePNG == null)
		{
			buffer = new byte[32];
		}
		else
		{
			buffer = global::YS_Assist.CreateSha256(this.charaFilePNG, this.CharaFileMark);
		}
		writer.Write(buffer);
		writer.Write(position);
		writer.Write(value);
		return true;
	}

	// Token: 0x060011C7 RID: 4551 RVA: 0x00090B9C File Offset: 0x0008ED9C
	public bool Load(string path = "", bool noSetPNG = false, bool noLoadStatus = true)
	{
		string path2 = this.ConvertCharaFilePath(path, false);
		if (!File.Exists(path2))
		{
			return false;
		}
		bool result;
		using (FileStream fileStream = new FileStream(path2, FileMode.Open, FileAccess.Read))
		{
			result = this.Load(fileStream, noSetPNG, noLoadStatus);
		}
		return result;
	}

	// Token: 0x060011C8 RID: 4552 RVA: 0x00090BFC File Offset: 0x0008EDFC
	public bool Load(string assetBundleName, string assetName, bool noSetPNG = false, bool noLoadStatus = true)
	{
		TextAsset textAsset = global::CommonLib.LoadAsset<TextAsset>(assetBundleName, assetName, false, string.Empty);
		if (null == textAsset)
		{
			return false;
		}
		global::AssetBundleManager.UnloadAssetBundle(assetBundleName, true, null);
		return this.Load(textAsset, noSetPNG, noLoadStatus);
	}

	// Token: 0x060011C9 RID: 4553 RVA: 0x00090C38 File Offset: 0x0008EE38
	public bool Load(TextAsset ta, bool noSetPNG = false, bool noLoadStatus = true)
	{
		if (null == ta)
		{
			return false;
		}
		bool result;
		using (MemoryStream memoryStream = new MemoryStream())
		{
			memoryStream.Write(ta.bytes, 0, ta.bytes.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			result = this.Load(memoryStream, noSetPNG, noLoadStatus);
		}
		return result;
	}

	// Token: 0x060011CA RID: 4554 RVA: 0x00090CAC File Offset: 0x0008EEAC
	public bool Load(Stream st, bool noSetPNG = false, bool noLoadStatus = true)
	{
		bool result;
		using (BinaryReader binaryReader = new BinaryReader(st))
		{
			result = this.Load(binaryReader, noSetPNG, noLoadStatus);
		}
		return result;
	}

	// Token: 0x060011CB RID: 4555 RVA: 0x00090CF4 File Offset: 0x0008EEF4
	public bool Load(BinaryReader reader, bool noSetPNG = false, bool noLoadStatus = true)
	{
		if (reader.BaseStream.Length == 0L)
		{
			return false;
		}
		long num = 0L;
		if (noSetPNG)
		{
			global::PngAssist.CheckPngData(reader, ref num, true);
		}
		else
		{
			this.charaFilePNG = global::PngAssist.LoadPngData(reader);
		}
		if (reader.BaseStream.Length - reader.BaseStream.Position == 0L)
		{
			global::Debug.LogWarning("ただのPNGファイルの可能性があります。");
			return false;
		}
		try
		{
			string a = reader.ReadString();
			if (a != this.CharaFileMark)
			{
				return false;
			}
			this.charaLoadFileVersion = reader.ReadInt32();
			if (this.charaLoadFileVersion > 2)
			{
				return false;
			}
			int num2 = reader.ReadInt32();
			SaveAssist.BlockHeader[] array = new SaveAssist.BlockHeader[num2];
			for (int i = 0; i < num2; i++)
			{
				array[i] = new SaveAssist.BlockHeader();
				array[i].LoadHeader(reader);
			}
			int num3 = 0;
			long position = reader.BaseStream.Position;
			this.previewInfo.previewLoadVersion = array[num3].version;
			num3++;
			this.customInfo.customLoadVersion = array[num3].version;
			if (this.customInfo.customLoadVersion <= this.customInfo.version)
			{
				reader.BaseStream.Seek(position + array[num3].pos, SeekOrigin.Begin);
				byte[] data = reader.ReadBytes((int)array[num3].size);
				if (!this.customInfo.LoadBytes(data, array[num3].version))
				{
					return false;
				}
			}
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.charaFileName);
			if ("ill_Sitri" != fileNameWithoutExtension)
			{
				this.customInfo.isConcierge = false;
			}
			num3++;
			this.coordinateInfo.coordinateLoadVersion = array[num3].version;
			if (this.coordinateInfo.coordinateLoadVersion <= this.coordinateInfo.version)
			{
				reader.BaseStream.Seek(position + array[num3].pos, SeekOrigin.Begin);
				byte[] data2 = reader.ReadBytes((int)array[num3].size);
				if (!this.coordinateInfo.LoadBytes(data2, array[num3].version))
				{
					return false;
				}
			}
			num3++;
			if (!noLoadStatus)
			{
				this.statusInfo.statusLoadVersion = array[num3].version;
				if (this.statusInfo.statusLoadVersion <= this.statusInfo.version)
				{
					reader.BaseStream.Seek(position + array[num3].pos, SeekOrigin.Begin);
					byte[] data3 = reader.ReadBytes((int)array[num3].size);
					if (!this.statusInfo.LoadBytes(data3, array[num3].version))
					{
						return false;
					}
				}
			}
			num3++;
			this.parameterInfo.parameterLoadVersion = array[num3].version;
			if (this.parameterInfo.parameterLoadVersion <= this.parameterInfo.version)
			{
				reader.BaseStream.Seek(position + array[num3].pos, SeekOrigin.Begin);
				byte[] data4 = reader.ReadBytes((int)array[num3].size);
				if (!this.parameterInfo.LoadBytes(data4, array[num3].version))
				{
					return false;
				}
			}
			long offset = position + array[num3].pos + array[num3].size;
			reader.BaseStream.Seek(offset, SeekOrigin.Begin);
			if (2 <= this.charaLoadFileVersion)
			{
				reader.BaseStream.Seek(32L, SeekOrigin.Current);
			}
			reader.BaseStream.Seek(8L, SeekOrigin.Current);
			reader.BaseStream.Seek(8L, SeekOrigin.Current);
			this.ChangeCoordinateType(this.statusInfo.coordinateType);
			return true;
		}
		catch (EndOfStreamException ex)
		{
			global::Debug.LogError("データが破損している可能性があります：" + ex.GetType().Name);
		}
		return false;
	}

	// Token: 0x060011CC RID: 4556 RVA: 0x00091110 File Offset: 0x0008F310
	public bool ChangeSavePng(string path, byte[] newPng)
	{
		if (newPng == null)
		{
			return false;
		}
		string path2 = this.ConvertCharaFilePath(path, false);
		if (!File.Exists(path2))
		{
			return false;
		}
		byte[] array = null;
		long num = 0L;
		long value = 0L;
		using (FileStream fileStream = new FileStream(path2, FileMode.Open, FileAccess.Read))
		{
			using (BinaryReader binaryReader = new BinaryReader(fileStream))
			{
				global::PngAssist.CheckPngData(binaryReader, ref num, true);
				if (binaryReader.BaseStream.Length - binaryReader.BaseStream.Position == 0L)
				{
					global::Debug.LogWarning("ただのPNGファイルの可能性があります。");
					return false;
				}
				try
				{
					long num2 = 16L;
					array = binaryReader.ReadBytes((int)(binaryReader.BaseStream.Length - num - num2));
					num = binaryReader.ReadInt64();
					value = binaryReader.ReadInt64();
				}
				catch (EndOfStreamException ex)
				{
					global::Debug.LogError("データが破損している可能性があります：" + ex.GetType().Name);
					return false;
				}
			}
		}
		if (array == null)
		{
			return false;
		}
		long value2 = (long)newPng.Length;
		using (FileStream fileStream2 = new FileStream(path2, FileMode.Create, FileAccess.Write))
		{
			using (BinaryWriter binaryWriter = new BinaryWriter(fileStream2))
			{
				binaryWriter.Write(newPng);
				binaryWriter.Write(array);
				binaryWriter.Write(value2);
				binaryWriter.Write(value);
			}
		}
		return true;
	}

	// Token: 0x060011CD RID: 4557 RVA: 0x000912C8 File Offset: 0x0008F4C8
	public bool LoadBlockData<T>(T blockInfo, string path) where T : global::BlockControlBase
	{
		if (blockInfo == null)
		{
			return false;
		}
		string path2 = this.ConvertCharaFilePath(path, false);
		if (!File.Exists(path2))
		{
			return false;
		}
		this.blockFileName = Path.GetFileNameWithoutExtension(path2);
		bool result;
		using (FileStream fileStream = new FileStream(path2, FileMode.Open, FileAccess.Read))
		{
			result = this.LoadBlockData<T>(blockInfo, fileStream);
		}
		return result;
	}

	// Token: 0x060011CE RID: 4558 RVA: 0x00091340 File Offset: 0x0008F540
	public bool LoadBlockData<T>(T blockInfo, string assetBundleName, string assetName) where T : global::BlockControlBase
	{
		TextAsset textAsset = global::CommonLib.LoadAsset<TextAsset>(assetBundleName, assetName, false, string.Empty);
		if (null == textAsset)
		{
			return false;
		}
		global::AssetBundleManager.UnloadAssetBundle(assetBundleName, true, null);
		return this.LoadBlockData<T>(blockInfo, textAsset);
	}

	// Token: 0x060011CF RID: 4559 RVA: 0x0009137C File Offset: 0x0008F57C
	public bool LoadBlockData<T>(T blockInfo, TextAsset ta) where T : global::BlockControlBase
	{
		bool result;
		using (MemoryStream memoryStream = new MemoryStream())
		{
			memoryStream.Write(ta.bytes, 0, ta.bytes.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			result = this.LoadBlockData<T>(blockInfo, memoryStream);
		}
		return result;
	}

	// Token: 0x060011D0 RID: 4560 RVA: 0x000913E0 File Offset: 0x0008F5E0
	public bool LoadBlockData<T>(T blockInfo, Stream st) where T : global::BlockControlBase
	{
		bool result;
		using (BinaryReader binaryReader = new BinaryReader(st))
		{
			result = this.LoadBlockData<T>(blockInfo, binaryReader);
		}
		return result;
	}

	// Token: 0x060011D1 RID: 4561 RVA: 0x00091428 File Offset: 0x0008F628
	public bool LoadBlockData<T>(T blockInfo, BinaryReader reader) where T : global::BlockControlBase
	{
		if (reader.BaseStream.Length == 0L)
		{
			return false;
		}
		long num = 0L;
		global::PngAssist.CheckPngData(reader, ref num, true);
		if (reader.BaseStream.Length - reader.BaseStream.Position == 0L)
		{
			global::Debug.LogWarning("ただのPNGファイルの可能性があります。");
			return false;
		}
		try
		{
			string a = reader.ReadString();
			if (a != this.CharaFileMark)
			{
				return false;
			}
			this.charaLoadFileVersion = reader.ReadInt32();
			if (this.charaLoadFileVersion > 2)
			{
				return false;
			}
			int num2 = reader.ReadInt32();
			SaveAssist.BlockHeader[] array = new SaveAssist.BlockHeader[num2];
			for (int i = 0; i < num2; i++)
			{
				array[i] = new SaveAssist.BlockHeader();
				array[i].LoadHeader(reader);
			}
			long position = reader.BaseStream.Position;
			int num3 = -1;
			for (int j = 0; j < array.Length; j++)
			{
				if (array[j].tagName.StartsWith(blockInfo.tagName))
				{
					num3 = j;
					break;
				}
			}
			if (num3 == -1)
			{
				return false;
			}
			int version = array[num3].version;
			if (version > blockInfo.version)
			{
				return false;
			}
			reader.BaseStream.Seek(position + array[num3].pos, SeekOrigin.Begin);
			byte[] data = reader.ReadBytes((int)array[num3].size);
			blockInfo.LoadBytes(data, version);
			if ("ill_Sitri" != this.blockFileName)
			{
				if (blockInfo is global::CharFileInfoPreview)
				{
					global::CharFileInfoPreview charFileInfoPreview = blockInfo as global::CharFileInfoPreview;
					charFileInfoPreview.isConcierge = 0;
				}
				else if (blockInfo is global::CharFileInfoCustomFemale)
				{
					global::CharFileInfoCustomFemale charFileInfoCustomFemale = blockInfo as global::CharFileInfoCustomFemale;
					charFileInfoCustomFemale.isConcierge = false;
				}
			}
			return true;
		}
		catch (EndOfStreamException ex)
		{
			global::Debug.LogError("データが破損している可能性があります：" + ex.GetType().Name);
		}
		return false;
	}

	// Token: 0x060011D2 RID: 4562 RVA: 0x00091668 File Offset: 0x0008F868
	public bool SaveBlockData<T>(T blockInfo, string path) where T : global::BlockControlBase
	{
		if (blockInfo == null)
		{
			return false;
		}
		string path2 = this.ConvertCharaFilePath(path, false);
		if (!File.Exists(path2))
		{
			return false;
		}
		global::CharFile charFile;
		if (this is global::CharMaleFile)
		{
			charFile = new global::CharMaleFile();
		}
		else
		{
			charFile = new global::CharFemaleFile();
		}
		if (charFile.Load(path, false, true))
		{
			charFile.CopyBlockData<T>(blockInfo);
			File.Delete(path);
			charFile.Save(path);
			return true;
		}
		return false;
	}

	// Token: 0x060011D3 RID: 4563 RVA: 0x000916DC File Offset: 0x0008F8DC
	public static float ClampEx(float value, float min, float max)
	{
		return value;
	}

	// Token: 0x040017D4 RID: 6100
	public const int CharaFileVersion = 2;

	// Token: 0x040017D5 RID: 6101
	public readonly string CharaFileMark = string.Empty;

	// Token: 0x040017D6 RID: 6102
	public readonly string CharaFileDirectory = string.Empty;

	// Token: 0x040017D7 RID: 6103
	public byte[] charaFilePNG;

	// Token: 0x040017D8 RID: 6104
	public string charaFileName = string.Empty;

	// Token: 0x040017D9 RID: 6105
	public int charaLoadFileVersion;

	// Token: 0x040017DA RID: 6106
	public string blockFileName = string.Empty;

	// Token: 0x040017E1 RID: 6113
	static int WIDESLIDER_083;
}
